<script setup lang="ts">
import { computed } from 'vue';
import { $t } from '@/locales';
import { enableStatusRecord } from '@/constants/business';

defineOptions({
  name: 'ShowDetailModal'
});

interface Props {
  /** row data */
  rowData?: Api.SystemManage.Dept | null;
}

const props = defineProps<Props>();

const visible = defineModel<boolean>('visible', {
  default: false
});

const title = computed(() => $t('page.manage.dept.deptDetail'));

function closeModal() {
  visible.value = false;
}
</script>

<template>
  <NModal v-model:show="visible" preset="dialog" :title="title" style="width: 800px; max-width: 90vw">
    <div v-if="rowData" class="space-y-16px">
      <NForm label-placement="left" :label-width="100" disabled>
        <NGrid responsive="screen" item-responsive>
          <NFormItemGi span="24 m:12" :label="$t('page.manage.dept.deptId')" path="deptId">
            <NInput :value="rowData.deptId || '-'" readonly />
          </NFormItemGi>

          <NFormItemGi span="24 m:12" :label="$t('page.manage.dept.deptName')" path="deptName">
            <NInput :value="rowData.deptName || '-'" readonly />
          </NFormItemGi>

          <NFormItemGi span="24 m:12" :label="$t('page.manage.dept.deptCode')" path="deptCode">
            <NInput :value="rowData.deptCode || '-'" readonly />
          </NFormItemGi>

          <NFormItemGi span="24 m:12" :label="$t('page.manage.dept.parentDept')" path="parentDept">
            <NInput :value="rowData.parentName || $t('page.manage.dept.rootDept')" readonly />
          </NFormItemGi>

          <NFormItemGi span="24 m:12" :label="$t('page.manage.dept.managerName')" path="manager">
            <NInput :value="rowData.managerName || '-'" readonly />
          </NFormItemGi>

          <NFormItemGi span="24 m:12" :label="$t('page.manage.dept.status')" path="status">
            <NTag :type="rowData.status === 1 ? 'success' : 'warning'">
              {{ rowData.status ? $t(enableStatusRecord[rowData.status]) : '' }}
            </NTag>
          </NFormItemGi>
        </NGrid>
      </NForm>
    </div>

    <template #action>
      <NSpace justify="end">
        <NButton @click="closeModal">{{ $t('common.close') }}</NButton>
      </NSpace>
    </template>
  </NModal>
</template>

<style scoped></style>
